package com.zzc.action;

import com.zzc.bean.Dining;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import com.zzc.service.DiningService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;

@Controller
public class DiningAction extends BaseAction{

	public DiningAction() {
		super();
	}
	private DiningService diningService;
	public DiningService getDiningService() {
		return diningService;
	}
	public void setDiningService(DiningService diningService) {
		this.diningService = diningService;
	}
	public void initData() throws ServletException, IOException {
		diningService.initCourses();
		getAll();
	}
	public void add(){
//		return "getCourses";
	}
	public void alert(){
		diningService.alterCourse();
	}
	public void getAll() throws ServletException, IOException {
		List<Dining> list_cours = diningService.getAll();
		HttpServletRequest request = ServletActionContext.getRequest();
		request.setAttribute("list_cours", list_cours);
//		BaseService.printAll(list_cours);
		request.getRequestDispatcher(getPath()+"/view/student/diningReceipt_lists.jsp").forward(request, getResponse());
	}
}
